package com.waitingresult.controller;

import com.waitingresult.common.Result;
import com.waitingresult.entity.UploadFileInfo;
import com.waitingresult.util.MinioUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;

/**
 * @Author: WangShuai
 * @CreateTime: 2022-11-21  09:45
 * @Description:
 * @Version: 1.0
 */
@RestController
@Slf4j
@RequestMapping("test")
public class TestController {

    @Resource
    private MinioUtil minioUtil;

    @PostMapping(value = "/upload",name = "文件上传")
    public Result minioUpload(@RequestParam(value = "file") MultipartFile file) {
        UploadFileInfo response = null;
        try {
            response = minioUtil.uploadFile(file);
        } catch (Exception e) {
            log.error("上传失败", e);
        }
        return Result.success(response);
    }
}
